// 注意点：l, r, mid需要使用long类型，mid取右中位数

int mySqrt(int x){
    long l = 0, r = x;
    while (l < r) {
        long mid = (l + r + 1)/2;
        long multi = mid*mid;
        if (multi > x) r = mid - 1;
        else if (multi < x) l = mid;
        else return (int)mid;
    }
    return (int)l;
}